<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        div {
            background-color: chartreuse;
            width: 50px;
            height: 50px;

            margin: 5px;
            float: left;

            border-radius: 50px;
            text-align:center;
            line-height: 50px;
        }

    </style>
</head>
<body>

    <div>A</div>
    <div>B</div>
    <div>C</div>
    <div>D</div>


    <script>
    

        // 第一：定义函数 - 实现任意两数之和

        // 第二：调用函数
        var divNodes = document.querySelectorAll("div");

        for(let i=0;i<divNodes.length;i++) {
            divNodes[i].onclick = function() {
               alert(i)
            };
        }
       
       







    </script>







</body>
</html>